package com.xyd.servlet;

import com.xyd.entity.Product;
import com.xyd.service.ProductSericve;
import com.xyd.service.impl.ProductServiceImpl;
import com.xyd.util.JsonUtil;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 类描述：
 *
 * @author 张吉哲
 * @date 2021/1/11 18:36
 */
@WebServlet("/productAdminProductTailServlet")
public class ProductAdminProductTailServlet extends HttpServlet {

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String epId_str = request.getParameter("epId");
    Long epId = null;
    if (epId_str != null && epId_str.length() > 0) {
      epId = Long.parseLong(epId_str);
    }
    ProductSericve productSericve = new ProductServiceImpl();
    Product product = productSericve.adminGetProductByEpId(epId);

    JsonUtil.toJson(response, product);
  }

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    doPost(request, response);
  }
}
